<template>
  <div
    class="common-layout__card1"
    :style="{ width: props.width, height: props.height }"
  >
    <el-container
      :style="{
        width: 'calc(' + props.width + 'px - 10px)',
      }"
    >
      <el-main>
        <VideoCover1
          :height="props.height - 50"
          :videoInfo="props.videoInfo!"
        ></VideoCover1>
      </el-main>
      <el-footer>
        <div class="video-card-footer">
          <div
            class="link text-hidden__1"
            :title="props.videoInfo?.title"
            @click="router.toVideo(props.videoInfo!.id)"
          >
            {{ props.videoInfo.title }}
          </div>
          <div class="link" @click="router.toHome(props.videoInfo!.user.id)">
            <el-icon>
              <Place />
            </el-icon>
            <div>{{ props.videoInfo.user.name }}</div>
            <i>{{ dateConversion(props.videoInfo.createTime) }}</i>
          </div>
        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { Place } from "@element-plus/icons-vue";
import { dateConversion } from "@/utils/common";
import router from "@/router/router";
import VideoCover1 from "@/components/VideoCover1.vue";
import { Video } from "@/types/video";

const props = defineProps({
  width: {
    type: Number,
    require: false,
    default: 200,
  },
  height: {
    type: Number,
    require: false,
    default: 180,
  },
  videoInfo: {
    type: Object as () => Video,
    required: true,
  },
});
</script>

<style lang="scss" scoped>
.common-layout__card1 {
  .el-main,
  .el-footer {
    padding: revert;
    overflow: hidden;
    text-align: left;
  }
  .video-card-footer {
    position: relative;
    width: 100%;
    height: 50px;
    color: black;
    font-weight: 500;
    font-family: PingFang SC, HarmonyOS_Medium, Helvetica Neue, Microsoft YaHei,
      sans-serif;

    & > div:first-child {
      text-overflow: ellipsis;
      overflow: hidden;
      word-break: break-all;
      white-space: nowrap;
    }
    & > div:last-child {
      display: flex;
      align-items: flex-end;
      position: absolute;
      bottom: 0;
      color: #696969;
      line-height: 15px;

      & > div {
        max-width: 80px;
        font-size: 13px;
        text-overflow: ellipsis;
        overflow: hidden;
        word-break: break-all;
        white-space: nowrap;
      }

      & > i:last-child {
        font-size: 12px;
        margin-left: 5px;
      }
    }
  }
}
</style>
